import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/parameter")
//继承了HttpServlet
public class ParameterServlet extends HttpServlet {
    private String password;

    // 约定, 客户端使用 query string 传递数据.
    // 例如: query string 形如: username=zhangsan&password=123
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");//这个方法可以通过key拿到values
        String password = req.getParameter("password");
        System.out.println("username=" + username);
        System.out.println("password=" + password);
        resp.getWriter().write("ok");//不然会返回空白页面,这么做可以检测是否返回空白页面
    }
}
